package com.lwc.cfdns.config;

import com.aliyun.oss.OSSClient;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * aliyunoss配置
 *
 * @author luwc
 * @title AliyunOssConfig
 * @description
 * @time 2023/9/19 10:51:16
 * @version: 1.0
 */
@ConfigurationProperties(prefix = "app.attachment.aliyunoss")
@Configuration
public class AttachmentAliyunOssConfig {
    private static String endpoint;
    private static String accessKeyId;
    private static String accessKeySecret;
    private static String bucketName;
    private static String uploadDomain;

    public static String getEndpoint() {
        return endpoint;
    }

    public synchronized void setEndpoint(String endpoint) {
        AttachmentAliyunOssConfig.endpoint = endpoint;
    }

    public static String getAccessKeyId() {
        return accessKeyId;
    }

    public synchronized void setAccessKeyId(String accessKeyId) {
        AttachmentAliyunOssConfig.accessKeyId = accessKeyId;
    }

    public static String getAccessKeySecret() {
        return accessKeySecret;
    }

    public synchronized void setAccessKeySecret(String accessKeySecret) {
        AttachmentAliyunOssConfig.accessKeySecret = accessKeySecret;
    }

    public static String getBucketName() {
        return bucketName;
    }

    public synchronized void setBucketName(String bucketName) {
        AttachmentAliyunOssConfig.bucketName = bucketName;
    }

    public static String getUploadDomain() {
        return uploadDomain;
    }

    public synchronized void setUploadDomain(String uploadDomain) {
        AttachmentAliyunOssConfig.uploadDomain = uploadDomain;
    }

    @Bean
    public OSSClient OSSClient() {
        return new OSSClient(endpoint, accessKeyId, accessKeySecret);
    }
}
